﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace SimpleFMMatrix.ViewModel
{
    public class ValuedDependencyObject : DependencyObject
    {
        private Action<double, double> OnValuedChanged = (o, n) => { };

        public double Value
        {
            get { return (double)GetValue(ValueProperty); }
            set { SetValue(ValueProperty, value); }
        }

        public static readonly DependencyProperty ValueProperty =
            DependencyProperty.Register("Value", typeof(double), typeof(ValuedDependencyObject),
                new PropertyMetadata(0.0,
                    (d, e) => ((ValuedDependencyObject)d).OnValuedChanged((double)e.OldValue, (double)e.NewValue)));

        internal ValuedDependencyObject(double _Value, Action<double, double> _OnValueChanged)
        {
            Value = _Value;

            if (_OnValueChanged != null)
                OnValuedChanged = _OnValueChanged;
        }
    }
}
